<#include "/common/include.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="修改参数"/>
<@addorEdit fromId="form-config-edit">   
       <input id="id" name="id" value="${cfg.id}"  type="hidden">
       <div class="form-group">
           <label class="col-sm-3 control-label"><span style="color: red; ">*</span>参数名称：</label>
           <div class="col-sm-8">
               <input id="paramName" name="paramName" class="form-control" type="text" value="${cfg.paramName?default("")}" required>
           </div>
       </div>
		<div class="form-group">
			<label class="col-sm-3 control-label"><span style="color: red; ">*</span>参数键名：</label>
			<div class="col-sm-8">
				<input id="paramKey" name="paramKey" class="form-control" type="text" value="${cfg.paramKey?default("")}" required>
				<span class="help-block m-b-none"><i class="fa fa-info-circle" style="color: red"></i>统一规范:请务必使用大写字母下划线定义.页面获取,如: <#noparse>${config.getKey("SYS_KEY")}</#noparse></span>
			</div>
		</div>
	    <div class="form-group">
		   <label class="col-sm-3 control-label"><span style="color: red; ">*</span>参数键值：</label>
		   <div class="col-sm-8">
			   <#--                <input id="paramValue" name="paramValue" class="form-control" type="text" required>-->
			   <textarea id="paramValue" rows="10" name="paramValue" class="form-control" required>${cfg.paramValue?default("")}</textarea>
		   </div>
	    </div>
		<div class="form-group">
			<label class="col-sm-3 control-label"><span style="color: red; ">(请慎重修改*)</span>系统内置：</label>
			<div class="col-sm-8">
				<#list dict.getType('sys_yes_no')>
					<#items as d>
						<#if d.status =='0' >
							<div class="radio-box">
								<input type="radio" id="${d.dictCode}" name="configType"
									   value="${d.dictValue}" <#if d.dictValue ==cfg.configType >checked</#if>>
								<label for="${d.dictCode}" text="${d.dictLabel}">${d.dictLabel}</label>
							</div>
						</#if>
					</#items>
				</#list>
			</div>
		</div>
		   <div class="form-group">
			   <label class="col-sm-3 control-label">备注：</label>
			   <div class="col-sm-8">
				   <textarea id="remark" name="remark" class="form-control">${cfg.remark?default("")}</textarea>
			   </div>
		   </div>
</@addorEdit>
<@footer>
<script>

	var prefix = baseURL + "sys/config";
	
	$("#form-config-edit").validate({
		onkeyup: false,
	    rules: {
	           paramKey: {
	            remote: {
	                url: prefix + "/checkConfigKeyUnique",
	                type: "POST",
	                dataType: "html",
	                data: {
	                    "id": function() {
	                    	return $("#id").val();
	                    },
	                    "paramKey": function() {
	                    	return opt.common.trim($("#paramKey").val());
	                    }
	                },
	                dataFilter: function(data, type) {
	                    return opt.validate.unique(data);
	                }
	            }
	        },
	    },
	    messages: {
	        "paramKey": {
	            remote: "参数键名已经存在"
	        }
	    },
	    focusCleanup: true
	});
	
	function submitHandler() {
	    if (opt.validate.form()) {
	    	opt.operate.save(prefix + "/edit", $('#form-config-edit').serialize());
	    }
	}
</script>
</@footer>
</@pageTheme>
